package com.xuelang.pipeline.client.resource;

import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.resource.dto.SpaceDTO;
import com.xuelang.pipeline.client.resource.dto.SpaceQuery;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import java.util.List;

/**
 * 空间服务API
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
public interface ISpaceService {

    /**
     * 查询空间列表(有过滤条件，可以分页)
     *
     * @param dtoPageParam 查询条件
     * @return
     */
    @PostMapping(value = "/pageList", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<SpaceDTO>> pageSpaceList(@RequestBody @Valid PageParam<SpaceQuery> dtoPageParam);

    /**
     * 查询空间列表(有过滤条件)
     *
     *
     * @param request
     * @param spaceQuery 查询条件
     * @return
     */
    @PostMapping(value = "/list", produces = "application/json;charset=utf-8")
    ApiResult<List<SpaceDTO>> conditionalSpaceList(HttpServletRequest request, @RequestBody @Valid SpaceQuery spaceQuery);

    /**
     * 新增空间
     *
     * @param spaceDTO 空间DTO
     * @return
     */
    @PostMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> addSpace(@RequestBody @Valid SpaceDTO spaceDTO);

    /**
     * 更新空间
     *
     * @param spaceDTO 空间DTO
     * @return
     */
    @PutMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> updateSpace(@RequestBody @Valid SpaceDTO spaceDTO);

    /**
     * 删除空间
     *
     * @param uuid 空间uuid
     * @return
     */
    @DeleteMapping(value = "/{uuid}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> deleteSpace(@PathVariable("uuid") String uuid);

    /**
     * 查询空间
     *
     * @param uuid 空间uuid
     * @return
     */
    @GetMapping(value = "/{uuid}", produces = "application/json;charset=utf-8")
    ApiResult<SpaceDTO> querySpace(@PathVariable("uuid") String uuid);

    /**
     * 是否存在关联环境限制
     *
     * @param spaceUuid 空间uuid
     * @return
     */
    @GetMapping(value = "/existsEnvironmentLimit/{uuid}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> existsEnvironmentLimit(@PathVariable("uuid") String spaceUuid);
}
